package com.reform.controller.phase;


import com.reform.pojo.phase.DepartmentPhase;
import com.reform.res.Result;
import com.reform.service.IDepartmentPhaseService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.sql.SQLException;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author mortale
 * @since 2021-10-25
 */
@Api(tags = "DepartmentPhaseController")
@RestController
@RequestMapping("/department-phase")
public class DepartmentPhaseController {

    @Autowired
    IDepartmentPhaseService departmentPhaseService;

    @ApiOperation(value = "绑定部门与批次的关系")
    @PostMapping("/addDepartmentPhase")
    @ApiImplicitParams({
    })
    public Result addDepartmentPhase(DepartmentPhase departmentPhase) throws SQLException {
        return departmentPhaseService.addDepartmentPhase(departmentPhase);
    }

    @ApiOperation(value = "更改部门与批次的关系")
    @PostMapping("/updateDepartmentPhase")
    @ApiImplicitParams({
    })
    public Result updateDepartmentPhase(DepartmentPhase departmentPhase) throws SQLException {
        return departmentPhaseService.updateDepartmentPhase(departmentPhase);
    }

    @ApiOperation(value = "查看部门与批次的关系")
    @GetMapping("/getAllDepartmentPhase")
    @ApiImplicitParams({
    })
    public Result getDepartmentPhase() throws SQLException {
        return departmentPhaseService.getDepartmentPhase();
    }


    @ApiOperation(value = "查看部门下批次的关系")
    @GetMapping("/getDepartmentPhaseByDepId")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "depId", value = "部门id", paramType = "query", dataTypeClass = Integer.class, required = true),
    })
    public Result getDepartmentPhaseByDepId(Integer depId) throws SQLException {
        return departmentPhaseService.getDepartmentPhaseByDepId(depId);
    }


    @ApiOperation(value = "查看批次下部门的关系")
    @GetMapping("/getDepartmentPhaseByPhaseId")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "phaseId", value = "阶段id", paramType = "query", dataTypeClass = String.class, required = true),
    })
    public Result getDepartmentPhaseByPhaseId(String phaseId) throws SQLException {
        return departmentPhaseService.getDepartmentPhaseByPhaseId(phaseId);
    }



}
